﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestAsmConverter
{
    [TestClass]
    public class SemanticSort
    {
        [TestMethod]
        public void TestMethod_dcl()
        {
            AsmShaderConverter.AsmShader.AsmSemantics inputs = AsmShaderConverter.AsmShader.AsmSemantics.dcl;
            Assert.AreEqual(2, Convert.ToInt32(inputs));
        }

        [TestMethod]
        public void TestMethod_dcl_position()
        {
            AsmShaderConverter.AsmShader.AsmSemantics inputs = AsmShaderConverter.AsmShader.AsmSemantics.dcl_position;
            Assert.AreEqual(1, Convert.ToInt32(inputs));
        }

        [TestMethod]
        public void TestMethod_dcl_color1()
        {
            AsmShaderConverter.AsmShader.AsmSemantics inputs = AsmShaderConverter.AsmShader.AsmSemantics.dcl_color1;
            Assert.AreEqual(15, Convert.ToInt32(inputs));
        }

        [TestMethod]
        public void TestMethod_dcl_texcoord0()
        {
            AsmShaderConverter.AsmShader.AsmSemantics inputs = AsmShaderConverter.AsmShader.AsmSemantics.dcl_texcoord0;
            Assert.AreEqual(5, Convert.ToInt32(inputs));
        }

        [TestMethod]
        public void TestMethod_SortAsmShaderInputsInHlsl()
        {
            AsmShaderConverter.AsmShader.AsmShaderFile vsasm = new AsmShaderConverter.AsmShader.AsmShaderFile(AsmShaderConverter.AsmShader.AsmShaderHelper.ShaderType.VertexShader, AsmShaderConverter.AsmShader.AsmShaderHelper.ShaderVersion.V5_0);

            AsmShaderConverter.HlslShader.HlslShaderFile vshlsl = new AsmShaderConverter.HlslShader.HlslShaderFile();

            vshlsl.InputStruct.StructTypeName = "instruct";
            vshlsl.InputStruct.VariableName = "invar";
            vshlsl.OutputStruct.StructTypeName = "outstruct";
            vshlsl.OutputStruct.VariableName = "outvar";
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_position v0"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_normal v1"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord v2"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord1 v3"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_color v4"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_color1 v5"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_position o0"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_color o1"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord8 o2"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord o3.xyz"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord1 o4"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord2 o5"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord4 o6"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord6 o7"));
            vshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord7 o8.xyz"));

            AsmShaderConverter.AsmShader.AsmShaderFile psasm = new AsmShaderConverter.AsmShader.AsmShaderFile(AsmShaderConverter.AsmShader.AsmShaderHelper.ShaderType.PixelShader, AsmShaderConverter.AsmShader.AsmShaderHelper.ShaderVersion.V5_0);

            AsmShaderConverter.HlslShader.HlslShaderFile pshlsl = new AsmShaderConverter.HlslShader.HlslShaderFile();

            pshlsl.InputStruct.StructTypeName = "instruct";
            pshlsl.InputStruct.VariableName = "invar";
            pshlsl.OutputStruct.StructTypeName = "outstruct";
            pshlsl.OutputStruct.VariableName = "outvar";
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_color v0.xyw"));
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord8 v1"));
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord v2.xyz"));
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord1 v3"));
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord2 v4"));
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord4 v5.xy"));
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl_texcoord7 v6.xyz"));
            pshlsl.AddInput(new AsmShaderConverter.AsmShader.AsmShaderInputOutput("dcl vPos.xy"));

            var inputLinesVS = vshlsl.GetInputLinesInput(vsasm, null);
            var OutputLinesVS = vshlsl.CreateCodeForOutputStruct(vsasm);
            var inputLinesPS = pshlsl.GetInputLinesInput(psasm, vshlsl);

            throw new NotImplementedException(" noch nicht fertig programmiert...");
        }
    }
}